--群管理菜单
return function (group,qq,msg,id,bl)
    
    --所有需要运行的app
    local app =   {
        {--!add
            check = function()--检查函数，拦截则返回true
                return msg:find("add ") == 1
            end,
            run = function()--匹配后进行运行的函数
                msg = msg:gsub("add ", "")
                local keyWord, answer = msg:match("(.+):(.+)")
                keyWord = kickSpace(keyWord)
                answer = kickSpace(answer)
                if not keyWord or not answer or keyWord:len() == 0 or answer:len() == 0 then
                    sendMessage("格式 add 123:123") return true
                end
                apiXmlInsert(tostring(group), "common", keyWord, answer)
                sendMessage("添加完成！\n" ..
                "词条：" .. keyWord .. "\n" ..
                "回答：" .. answer)
                return true
            end,
            explain = function()--功能解释，返回为字符串，若无需显示解释，返回nil即可
                return "add    关键词:回答"
            end
        },
        {--!delall
            check = function()
                return msg:find("delall ") == 1
            end,
            run = function()
                keyWord = msg:gsub("delall ", "")
                keyWord = kickSpace(keyWord)
                apiXmlDelete(tostring(group), "common", keyWord)
                sendMessage("删除完成！\n" ..
                "词条：" .. keyWord)
                return true
            end,
            explain = function()
                return "delall 关键词"
            end
        },
        {--!del
            check = function()
                return msg:find("del ") == 1
            end,
            run = function()
                msg = msg:gsub("del ", "")
                local keyWord, answer = msg:match("(.+):(.+)")
                keyWord = kickSpace(keyWord)
                answer = kickSpace(answer)
                if not keyWord or not answer or keyWord:len() == 0 or answer:len() == 0 then
                    sendMessage("格式 del 123:123") return true
                end
                apiXmlRemove(tostring(group), "common", keyWord, answer)
                sendMessage("删除完成！\n" ..
                "词条：" .. keyWord .. "\n" ..
                "回答：" .. answer)
                return true
            end,
            explain = function()
                return "del     关键词:回答"
            end
        },
        {--!list
            check = function()
                return msg:find("list ") == 1
            end,
            run = function()
                keyWord = msg:gsub("list ", "")
                keyWord = kickSpace(keyWord)
                sendMessage("本群词库内容：\n" .. apiXmlListGet(tostring(group), "common", keyWord) .. "\n\n" ..
                "全局词库内容：\n" .. apiXmlListGet("", "common", keyWord))
                return true
            end,
            explain = function()
                return "list     关键词"
            end
        },
        {--获取成员信息
            check = function()
                return msg:find("查看资料") == 1
            end,
            run = function()
                local dqq = msg:match("(%d+)")
                local t = cqGetMemberInfo(tonumber(group), tonumber(dqq), true)
                local info = require("app.common.groupmemberinfo")
                sendMessage(info(t))
                return true
            end,
            explain = function()
                return "查看资料 qq "
            end
        },
        {--获取全部成员信息
            check = function()
                return msg:find("查看全部资料") == 1
            end,
            run = function()
                local dqq = msg:match("(%d+)")
                local tlist = cqGetMemberList(tonumber(group))
                local num = tlist[0]
                local list = tlist[1]

                for i = 0, num do
                    local info = require("app.groupmemberinfo")
                    sendMessage(info(list[i]))
                end
                return true
            end,
            explain = function()
                return "查看全部资料"
            end
        },
        {--解除禁言
            check = function()
                return msg:find("解除禁言") == 1
            end,
            run = function()
                local q = tonumber(msg:match("(%d+)"))
                if q == nil then
                    return "命令： 解除禁言@某个人"
                end
                cqSetGroupBanSpeak(group, q, -1)
                return true
            end,
            explain = function()
                return "解除禁言"
            end
        },
        {--解除全员禁言
            check = function()
                return msg:find("解除全员禁言") == 1
            end,
            run = function()
                cqSetGroupWholeBanSpeak(group, false)
                return true
            end,
            explain = function()
                return "解除全员禁言"
            end
        },
        {--全员禁言
            check = function()
                return msg:find("全员禁言") == 1
            end,
            run = function()
                cqSetGroupWholeBanSpeak(group, true)
                return true
            end,
            explain = function()
                return "全员禁言"
            end
        },
        {--分享群名片
            check = function()
                return msg:find("分享群名片") == 1
            end,
            run = function()
                local g = tonumber(msg:match("(%d+)"))
                if g == nil then g = 418106020 end
                local card = cqCqCode_ShareCard("group", g)
                sendMessage(card)
                return true
            end,
            explain = function()
                return "分享群名片 "
            end
        },
        {--分享链接
            check = function()
                return msg:find("创建链接") == 1
            end,
            run = function()
                local img,link,title,content = msg:match("\r\n(.+)\r\n(.+)\r\n(.+)\r\n(.+)")
                if img == nil then
                    sendMessage("图片路径为空")
                elseif link == nil then
                    sendMessage("链接路径为空")
                elseif title == nil then
                    sendMessage("标题为空")
                elseif content == nil then
                    sendMessage("内容为空")
                else
                    local link = cqCqCode_ShareLink(link, title, content, img)
                    sendMessage(link)
                end
                return true
            end,
            explain = function()
                return "创建链接 "
            end
        },
        {--分享QQ名片
            check = function()
                return msg:find("分享QQ名片") == 1
            end,
            run = function()
                local q = tonumber(msg:match("(%d+)"))
                if q == nil then q = 919825501 end
                local card = cqCqCode_ShareCard("qq", q)
                sendMessage(card)
                return true
            end,
            explain = function()
                return "分享QQ名片 "
            end
        },
        {--分享位置
            check = function()
                return msg:find("创建位置") == 1
            end,
            run = function()
                local localtion,description,E,W,S = msg:match("\r\n(.+)\r\n(.+)\r\n(.+)\r\n(.+)\r\n(.+)")
                if localtion == nil then
                    sendMessage("地点为空")
                elseif description == nil then
                    sendMessage("说明为空")
                elseif E == nil then
                    E=0
                elseif W == nil then
                    W=0
                elseif S == nil then
                    S=0
                else
                    local gps = cqCqCode_ShareGPS(localtion,description,E,W,S)
                    sendMessage(gps)
                end
                return true
            end,
            explain = function()
                return "创建位置"
            end
        },
        {--该群不说话
            check = function()
                return msg:find("%[CQ:at,qq=" .. cqGetLoginQQ() .. "%]") and msg:find("闭嘴")or msg:find("%[CQ:at,qq=" .. cqGetLoginQQ() .. "%]") and msg:find("别说话")
            end,
            run = function()
                apiXmlSet("","Shutup",tostring(group),"f")
                sendMessage("我先走了,有事再叫我噢！")
                return true
            end,
            explain = function()
                return "闭嘴  或者 别说话"
            end
        },
        {--发图片
            check = function()
                return msg:find("%[CQ:at,qq=" .. cqGetLoginQQ() .. "%]") and msg:find("图")
            end,
            run = function()
                if msg:find("不") or msg:find("别") then
                    apiXmlSet("","noimage",tostring(group),"f")
                    sendMessage("不发啦，听你的")
                    return true
                end

                apiXmlSet("","noimage",tostring(group),"t")
                sendMessage("可以发图咯")
                return true
            end,
            explain = function()
                return "不,别/图"
            end
        },
        {--发语音
            check = function()
                return msg:find("%[CQ:at,qq=" .. cqGetLoginQQ() .. "%]") and msg:find("语音")
            end,
            run = function()
                if msg:find("不") or msg:find("别") then
                    apiXmlSet("","norecord",tostring(group),"f")
                    sendMessage("好的呢")
                    return true
                end

                apiXmlSet("","norecord",tostring(group),"t")
                sendMessage("可以发语音咯")
                return true
            end,
            explain = function()
                return "语音"
            end
        },
        {--进群欢迎语
            check = function()
                return msg:find("欢迎语")==1
            end,
            run = function()
                local key = msg:gsub("欢迎语","")
                key = kickSpace(key)
                apiXmlSet(tostring(group),"welcome","welcome",key)
                sendMessage("设置成功")
                return true
            end,
            explain = function()
                return "欢迎语"
            end
        },
        {--邀请统计回复设置
            check = function()
                return msg:find("邀请统计回复")==1
            end,
            run = function()
                local key = msg:gsub("邀请统计回复","")
                key = kickSpace(key)
                apiXmlSet(tostring(group),"invitcountrel","countrel",key)
                sendMessage("设置成功")
                return true
            end,
            explain = function()
                return "邀请统计回复"
            end
        },
        {--邀请成功回复设置
            check = function()
                return msg:find("邀请成功回复")==1
            end,
            run = function()
                local key = msg:gsub("邀请成功回复","")
                key = kickSpace(key)
                apiXmlSet(tostring(group),"invitsuccess","success",key)
                sendMessage("设置成功")
                return true
            end,
            explain = function()
                return "邀请成功回复"
            end
        },
        {--控制邀请统计
            check = function()
                return msg:find("邀请统计")==1
            end,
            run = function()
                local key = msg:gsub("邀请统计","")
                key = kickSpace(key)
                if key == "开启" then
                    apiXmlSet(tostring(group),"invitcount","is","1")
                elseif key == "关闭" then
                    apiXmlSet(tostring(group),"invitcount","is","0")
                end
                sendMessage("设置成功")
                return true
            end,
            explain = function()
                return "邀请统计开启/关闭"
            end
        },
        {--退群通知消息设置
            check = function()
                return msg:find("退群通知消息")==1
            end,
            run = function()

                if msg:find("退群通知消息主动")==1 then
                    local key = msg:gsub("退群通知消息主动","")
                    key = kickSpace(key)
                    apiXmlSet(tostring(group),"groupoutrel","passive",key)
                elseif msg:find("退群通知消息被动")==1 then
                    local key = msg:gsub("退群通知消息被动","")
                    key = kickSpace(key)
                    apiXmlSet(tostring(group),"groupoutrel","active",key)
                end
                sendMessage("设置成功")
                return true
            end,
            explain = function()
                return "退群通知消息主动/被动"
            end
        },
        {--禁言
            check = function()
                return msg:find("禁言%[CQ:at,qq=") == 1
            end,
            run = function()
                local v = tonumber(msg:match("(%d+)%]"))
                local dmsg = msg:gsub("禁言%[CQ:at,qq="..v.."%]","")
                local t = tonumber(dmsg:match("(%d+)"))
                if t then
                    cqSetGroupBanSpeak(group, v, t * 60)
                    sendMessage( cqCode_At(qq) .. "已将" .. tostring(v) .. "禁言" .. tostring(t) .. "分钟")
                    return true
                end
            end,
            explain = function()
                return "禁言"
            end
        },
        {--退群通知控制
            check = function()
                return msg:find("退群通知")==1
            end,
            run = function()
                local key = msg:gsub("退群通知","")
                key = kickSpace(key)
                if key == "开启" then
                    apiXmlSet(tostring(group),"groupout","is","1")
                elseif key == "关闭" then
                    apiXmlSet(tostring(group),"groupout","is","0")
                end
                sendMessage("设置成功")
                return true
            end,
            explain = function()
                return "退群通知开启/关闭"
            end
        },
        {--踢人
            check = function()
                return msg:find("踢人") == 1
            end,
            run = function()
                local q = tonumber(msg:match("(%d+)"))
                cqSetGroupMemberRemove(group, q, false)
                sendMessage("被操作帐号: "..q.." 不再接收加群申请:否")
                return true
            end,
            explain = function()
                return "踢人"
            end
        },
        {--开奖
            check = function()
                return msg:find("开奖") == 1
            end,
            run = function()
                local number = apiXmlListGet("","Luck",os.date("%Y-%m-%d",os.time()))
                if number == "" then
                    sendMessage("今日没有人抽奖")
                end
                numbers = number:match("(.-)一"):trim():split("\n")
                local random = math.random(#numbers)
                sendMessage("今日中奖号码为：\n"..numbers[random])
                return true
            end,
            explain = function()
                return "开奖"
            end
        },
        {
            --记录语音开启
            check = function()
                return msg:find('记录语音') == 1
            end,
            run = function()
                local key = msg:gsub("记录语音","")
                if key=="开启" then
                    apiXmlSet("record","recordconfig",tostring(group),"t")
                    sendMessage("开启语音记录功能")
                elseif key == "关闭" then
                    apiXmlSet("record","recordconfig",tostring(group),"f")
                    sendMessage("关闭语音记录功能")
                end
                return true
            end,
            explain = function()
                return '记录语音开启/关闭'
            end
        },
        {
            --语音播放
            check = function()
                return msg:find('语音播放') == 1
            end,
            run = function()
                local key = msg:match('(%d+)')
                local name = apiXmlGet("record","record",tostring(key))
                sendMessage(cqCqCode_Record(name))
                return true
            end,
            explain = function()
                return '语音播放'
            end
        },
        {
            --语音数量
            check = function()
                return msg:find('语音数量') == 1
            end,
            run = function()
                local total = apiXmlGet("record","record","total")
                sendMessage("当前共记录语音"..total.."条")
                return true
            end,
            explain = function()
                return '语音数量'
            end
        },
        {
            --语音自定义
            check = function()
                return msg:find('语音自定义') == 1
            end,
            run = function()
                local keys = kickSpace(msg:gsub("语音自定义","")):split(":")
                local name = apiXmlGet("record","record",tostring(keys[1]))
                apiXmlInsert('record', 'userecord', keys[2],name)
                sendMessage("添加完成!")
                return true
            end,
            explain = function()
                return '语音自定义 编号:标签'
            end
        },
        {
            --删除语音自定义
            check = function()
                return msg:find('删除语音自定义') == 1
            end,
            run = function()
                local key = msg:gsub("删除语音自定义","")
                apiXmlDelete('record', 'userecord', key)
                sendMessage("删除成功!")
                return true
            end,
            explain = function()
                return '删除语音自定义'
            end
        },
        {
            --开启关闭自动同意进群
            check = function()
                return msg:find('同意进群') == 1
            end,
            run = function()
                local key = msg:gsub("同意进群","")
                if key=="开启" then
                    apiXmlSet("","groupagree",tostring(group),"t")
                    sendMessage("开启自动同意进群")
                elseif key == "关闭" then
                    apiXmlSet("","groupagree",tostring(group),"f")
                    sendMessage("关闭自动同意进群")
                end
                return true
            end,
            explain = function()
                return '同意进群开启/关闭'
            end
        },
    }
    
    -- 执行功能 获取菜单
    if bl then
        for i = 1, #app do
            if app[i].check and app[i].check() then
                return app[i].run()
            end
        end
    else
        local m = ""
        local flag = true
        for i = 1, #app do
            local appExplain = app[i].explain and app[i].explain()
            if appExplain then
                m = m ..appExplain
                if flag then
                    m = m .. "    "
                    flag = nil
                else
                    m = m .. "\n"
                    flag = true
                end
            end
        end
        sendMessage(m)
        return true
    end
end